<?php
require_once 'bbs/include/common.inc.php';
require_once 'classes/include.php';

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>北京市京师律师学校 - 招生就业</title>
<link rel="stylesheet" href="./css/base.css" type="text/css"/>
<link rel="stylesheet" href="./css/superfish.css" type="text/css"/>
<link rel="stylesheet" href="./css/form.css" type="text/css"/>
<link rel="stylesheet" href="./css/ui.datepicker.css" type="text/css"/>

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/ui.datepicker.js"></script>
<script type="text/javascript" src="js/hoverIntent.js"></script>
<script type="text/javascript" src="js/superfish.js"></script>
<script type="text/javascript" src="js/common.js"></script>

<script type="text/javascript">
$(function()
{
	$("#navigationMenu").superfish();
});
</script>
</head>
<body>
<div class="PageContainer">
	<? 
		include("classes/page_header.php"); 	
	?>
	<div class="PageContent">
		<div class="PageContentBlock PicturesMarquee Level2">
			<img src="images/banner/lv2page.jpg"/>
		</div>
		
		<div class="PageContentBlock SectionPath">
			<p>
				<span class="NormalText">您现在的位置：</span>
				<span class="Path">
					<a href="./index.php">首页</a> &gt; <a href="/topic.php?id=900">招生就业</a> &gt; <span class="CurrentSection">在线报名</span>
				</span>
			</p>
		</div>
		
		<div class="PageContentBlock TwoColumnsContainer">
			<? include("classes/page_left.php"); ?>
			
			<div class="TwoColumnsContent_Right">
				<img style="" src="images/lv2articlesample.jpg">				
				<div id='applicant_form'>		
					<form action='#' method='POST' id="form" name="form" class="register_form">									
					<table width="" cellspacing="0" cellpadding="0" border="0" class="f14">
						<tr>
							<td class='tr' width='210'>姓　　名：</td>
							<td><div class="pr"><input class='text' type='text' name='applicant_username' id='applicant_username' value='' mod="isempty" msg="请正确填写您的姓名"></div></td>
						</tr>
						<tr>
							<td class='tr'>性　　别：</td>
							<td>
								<select name='sex' id='sex'>
									<option value=1>男</option>
									<option value=2>女</option>
								</select>
							</td>
						</tr>
						<tr>
							<td class='tr'>出生日期：</td>
							<td><input class='text' type='text' name='birth_date' id='birth_date' value=''></td>
						</tr>
						<tr>
							<td class='tr'>单　　位：</td>
							<td><input class='text' type='text' name='company' id='company' value=''></td>
						</tr>
						<tr>
							<td class='tr'>手　　机：</td>
							<td>
		                		<div class="pr"><input class='text' type="text" id="mobile" name="mobile" value="" mod="isempty|ismobile" msg="手机号不能为空|手机号码不正确"></div>	                		
		                	</td>
						</tr>
						<tr>
							<td class='tr'>电子邮件：</td>
							<td>
								<div class="pr"><input class='text' type="text" id="email" name="email" value="" mod="isempty|isemail" msg="邮箱地址不能为空|邮箱地址不正确"></div>
							</td>
						</tr>
						<tr>
							<td class='tr'>备　　注：</td>
							<td>
								<textarea name='remark' id='remark'></textarea>
							</td>
						</tr>
						<tr>
							<td class='tr'>验&nbsp;证&nbsp;码：</td>
							<td>
								<div class="pr">
									<input name='validate_code' class='text' id='validate_code' value='' >
									<span style='margin-left:5px;'><img class="text" id="auth_code_img" style='width:80px; height:27px' src="/classes/create_validate_code.php"></span>
									<span><a href="javascript:get_auth_code();">看不清</a></span>
									<div class="error" id='code_error' style='display:none; left:300px; width:80px;'>验证码错误<span style='right:90px;'></span></div>
								</div>
							</td>
						</tr>
					</table>
					<div style='text-align: center; margin-top:20px'><input type='button' class='bn97red' onclick="ajax_submit()" value="提 交" ></div>	 				
					</form>
				</div>
				<div id='add_res' style='display:none'></div>
			</div>
		</div>
		<? include("classes/page_footer.php"); ?>		
	</div>
	
	<script>
		datepicker('birth_date');
		
		function ajax_submit()
		{
			
			
			if(validate_form('form'))
			{
				if($('#validate_code').val() == '')
				{
					$('#code_error').show();
					$('#validate_code').attr('class', 'text error');
					return;
				}
				
				var applicant_username	= $('#applicant_username').val();
				var sex 				= $('#sex').val();
				var birth_date 			= $('#birth_date').val();
				var company 			= $('#company').val();
				var mobile 				= $('#mobile').val();
				var email 				= $('#email').val();
				var remark 				= $('#remark').val();
				var validate_code 		= $('#validate_code').val();				
				
				$.ajax({
					url:'ajax.php?act=applicant',
					type:'post',
					data:'applicant_username='+applicant_username+'&sex='+sex+'&birth_date='+birth_date+'&company='+company+'&mobile='+mobile+'&email='+email+'&remark='+remark+'&validate_code='+validate_code,
					success:function(res)
					{
						if(res == 1)
						{				
							//如果添加成功则发送邮件
							$.ajax({
								url:'ajax.php?act=send_email',
								type:'post',
								data:'email='+email+'&applicant_username='+applicant_username,
								success:function(res)
								{
									//alert(res);
								}
							})
									
							$('#add_res').show();
							$('#add_res').html('添加成功');
							$('#applicant_form').hide();							
						}
						else if(res == 2)
						{
							$('#code_error').show();
							$('#validate_code').attr('class', 'text error');
						}
						else
						{
							$('#add_res').show();
							$('#add_res').html('添加失败');
						}
					}
				});
			}
			
			return false;
		}
		
		function get_auth_code()
		{
			var tm = Math.round((Math.random()) * 100000000);
			$("#auth_code_img")[0].src = '/classes/create_validate_code.php?'+tm;
		}

	</script>
</div>
</body>
</html>